<?php

$domains = file('./1127.txt');
foreach($domains as $d){
  //asp_365hjdcom	1615919321	正在运行	www.365hjd.com.sdshuhua.com.cn	* 全部未分配 *	80		
  $reg = '/(www\.\w+\.\w+)\.sdshuhua.com.cn/is' ;
  preg_match($reg,$d,$match);
  if(empty($match)){
    continue;
  }
  $www_d = $match[1];
  $_d = substr($match[1],4);
  $str = <<<EOF
  <VirtualHost *:80>
    ServerName {$www_d}
    ServerAlias {$_d}
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPass / http://{$www_d}.sdshuhua.com.cn/
    ProxyPassReverse / http://{$www_d}.sdshuhua.com.cn/
  </VirtualHost>
EOF;

  echo $str ;
  echo "\n" ;

}

//print_r($match);
	//print_r($d);
die;


foreach($domains as $d){

  $d = trim($d);
  //print_r(substr($d,-2,2));
  //die;
  if(substr($d,-6,6)=='com.cn'){
    $www_d = 'www.'.substr($d,0,strlen($d)-6).'.com.cn';
    $_d = substr($d,0,strlen($d)-6).'.com.cn';
  }elseif(substr($d,-2,2)=='cn'){
    $www_d = 'www.'.substr($d,0,strlen($d)-2).'.cn';
    $_d = substr($d,0,strlen($d)-2).'.cn';
  }elseif(substr($d,-3,3)=='com'){
    $www_d = 'www.'.substr($d,0,strlen($d)-3).'.com';
    $_d = substr($d,0,strlen($d)-3).'.com';
  }elseif(substr($d,-3,3)=='net'){
    $www_d = 'www.'.substr($d,0,strlen($d)-3).'.net';
    $_d = substr($d,0,strlen($d)-3).'.net';
  }

$str = <<<EOF
  <VirtualHost *:80>
    ServerName {$www_d}
    ServerAlias {$_d}
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPass / http://{$www_d}.sdshuhua.com.cn/
    ProxyPassReverse / http://{$www_d}.sdshuhua.com.cn/
  </VirtualHost>
EOF;

echo $str ;
echo "\n" ;

}
